f=open("D:/test7-6.txt")
txts=f.readlines()
str1=""
str2=""
num=0
score=[]
list1=[]
list2=[]
list3=[]
for i in txts:
    ls=i.rstrip().split(",")

    score.append(ls)
score[0].append("平均成绩")

for h in score[1:]:
    avg1=round((int(h[2])*10+int(h[3])*10+int(h[4])*10)/3)/10.0   #四舍五入
    h.append(str(avg1))
#print(score)
for i in score[0:1]:
    list1.append([i[0],i[1],i[5]])

for i in score[1:6]:
    list1.append([i[0],i[1],i[5]])

f=open("D:/test7-8.txt",'w')

for i in list1:

    f.writelines([i[0]+",",i[1]+",",i[2]])
    f.write(";")

f.close()

f=open("D:/test7-8.txt")
a=f.read()
ls=a.split(";")
for j in ls:
    jlist=j.split(",")
    list2.append(jlist)
for i in list2[1:len(list2)-1]:
    i[2]=float(i[2])
    list3.append([i[0],i[1],i[2]])
#print(list3)
list3.sort(key=lambda x:x[2],reverse=True)
str1="名次\t"
for i in list2[0:1]:
    str1=str1+str(i[0])+"\t"+str(i[1])+"\t"+str(i[2])
print(str1)
for i in range(0,len(list3)):
    for j in range(len(list3[i])):

        str2=str2+str(list3[i][j])+"\t"
    print(str(i+1)+"\t"+str2)
    str2=""